# --------------------------------------------------
# 1. Let's try build on arm? You know what? Why don't we just try package a
# vendor version?

# 1.1 get boost
mkdir .pre
cd .pre
# wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.bz2
wget https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2 -Oboost_1_86_0.tar.bz2
s='1bed88e40401b2cb7a1f76d4bab499e352fa4d0c5f31c0dbae64e24d34d7513b'
sha256sum boost_1_86_0.tar.bz2
# Invoke-WebRequest https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2

# 1.2 get rocksdb
wget https://github.com/facebook/rocksdb/archive/refs/tags/v9.5.2.tar.gz
# Invoke-WebRequest https://github.com/facebook/rocksdb/archive/refs/tags/v9.5.2.zip -OutFile v9.5.2.zip

# 1.3 add protobuf and build
git clone -b v27.3 --depth 1 https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
cd ..

# 2. zip

# 3. build
# 3.1 build rocksdb
tar zxf v9.5.2.tar.gz
# it says, the CMakeLists.txt is for windows, for unix, it's gonna build a while
x=rocksdb-9.5.2
make -C $x \
     OBJ_DIR=`pwd`/build-rocksdb \
     static_lib

make -C $x \
     OBJ_DIR=`pwd`/build-rocksdb \
     clean

# Note: the OBJ_DIR and PREFIX are relative to the cwd (-C)
make -C $x \
     OBJ_DIR=build-rocksdb \
     PREFIX=`pwd`/installed-rocksdb \
     install

# 3.2 build protobuf
x=protobuf
cmake \
    -DABSL_PROPAGATE_CXX_STD=ON \
    -DABSL_BUILD_TEST_HELPERS=OFF \
    -Dprotobuf_BUILD_TESTS=OFF \
    -S $x -B build-$x

cmake --build build-$x
cmake --install build-$x --prefix installed-$x
sudo ln -s $PWD/installed-$x/bin/protoc /usr/local/bin/protoc
protoc --version

# 3.3 build boost
tar -xf boost_1_86_0.tar.bz2 --verbose
